#include <iostream>
using namespace std;

const int kMaxN = 300;

struct Student {
  int id, total, chinese;
} students[kMaxN];

int main() {
  int n;

  cin >> n;
  for (int id = 1; id <= n; id++) {
    int c, m, e;

    cin >> c >> m >> e;
    students[id - 1].id = id;
    students[id - 1].chinese = c;
    students[id - 1].total = c + m + e;
  }
  for (int i = 0; i < 5; i++) {
    int max_id = i;
    for (int j = i; j < n; j++) {
      if (students[max_id].total < students[j].total ||
          (students[max_id].total == students[j].total && students[max_id].chinese < students[j].chinese) ||
          (students[max_id].total == students[j].total && students[max_id].chinese == students[j].chinese && students[max_id].id > students[j].id)) {
        max_id = j;
      }
    }
    swap(students[i], students[max_id]);
    cout << students[i].id << ' ' << students[i].total << endl;
  }
  return 0;
}